package aecs

import (
	"fmt"

	"github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
)

// 云服务器绑定公网 IP的接口
func (c *Client) AllocatePublicIpAddress(req *ecs.AllocatePublicIpAddressRequest) (*ecs.AllocatePublicIpAddressResponse, error) {
	client := c.Client
	req.Method = "GET"
	req.Port = c.Port
	response, err := client.AllocatePublicIpAddress(req)

	if err != nil {
		return nil, fmt.Errorf("Error creating instance %w", err)
	}

	return response, nil
}
